import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/HomeView_N.vue'),
    redirect: '/homepage',
    children: [
      {path:'/square',component: () => import('../views/square/SquareView.vue'),meta:{title:"接单广场"}},
      {path:'/user', component: () => import('../views/user/UserView.vue'), meta:{title:"用户中心"}},
      {path:'/order',component: () => import('../views/order/OrderView.vue'),meta:{title:"订单中心"}},
      {path:'/choose',component: () => import('../views/home/choose.vue'),meta:{title:"用户选择中心"}},
      {path:'/purse',component: () => import('../views/user/PurseView.vue'),meta:{title:"充值中心"}},
      {path:'/test',component: () => import('../views/user/testView.vue'),meta:{title:"测试"}},
      {path:'/more',component: () => import('../views/menuItems/ClassificationView.vue'),meta:{title:"更多功能"}},
      {path:'/homepage',component: () => import('../views/home/homePageView.vue'),meta:{title:"校园广场"}},
      {
        path:'/rider',
        name:'rider',
        component: () => import('../views/rider/RiderView.vue'),
        redirect: '/rider/homepage',
        children: [
          {path:'/rider/homepage',component: () => import('../views/rider/HomepageView.vue'),meta:{title:"骑手主页"}},
          {path:'/rider/order',component: () => import('../views/rider/OrderListView.vue'),meta:{title:"骑手订单"}},
          {path:'/rider/data',component: () => import('../views/rider/DataCenterView.vue'),meta:{title:"数据中心"}},
          {path:'/rider/income',component: () => import('../views/rider/IncomeView.vue'),meta:{title:"收入中心"}},
          {path:'/rider/appeal',component: () => import('../views/rider/AppealView.vue'),meta:{title:"申诉中心"}},
          {path:'/rider/appeal',component: () => import('../views/rider/Appeal.vue'),meta:{title:"申诉中心"}},
          {path:'/rider/rules',component: () => import('../views/rider/RiderRulesView.vue'),meta:{title:"骑手规则"}},
          {path:'/rider/setting',component: () => import('../views/rider/RiderSettings.vue'),meta:{title:"骑手设置"}},
        ]
      },
      {path:'/become',component: () => import('../views/rider/BecomeRiderView.vue'),meta:{title:"成为骑手"}}
    ]
  },
  {
    path:'/login',
    component: ()=>import('../views/Login.vue'),
    meta:{title:"校园帮，你的生活小帮手"}
  },{path:'/launchOrder',component: () => import('../views/order/launchOrder.vue'),meta:{title:"新增订单"}},
    {path:'/card',component: () => import('../views/order/orderCard.vue'),meta:{title:"订单详情"}},
    {path:'/complain',component: () => import('../views/order/orderComplain.vue'),meta:{title:"订单投诉"}},
    {path:'/assess',component: () => import('../views/order/orderAssess.vue'),meta:{title:"订单评价"}},
    {path:'/pay',component: () => import('../views/order/payView.vue'),meta:{title:"订单评价"}},
    {path:'/success',component: () => import('../views/order/successView.vue'),meta:{title:"成功界面"}},
    {path:'/launchCard',component: () => import('../views/card/launchCard.vue'),meta:{title:"成功界面"}},
  {
    path:'/message',
    component: () => import('../views/message/MessageView.vue'),
    meta:{
      title:"我的消息"
    }
  },
  {
    path: '/search',
    component:() => import('../views/home/Search.vue')
  },
  {
    path:'/setting',
    component: () => import('../views/user/SettingView.vue'),
    meta:{
      title:"设置中心"
    }
  },
  {
    path: '/reception',
    component: () => import('../views/order/receptionOrder.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

router.afterEach((to, from) => {
  document.title = to.meta.title //在全局后置守卫中获取路由元信息设置title
})

export default router
